tosca_definitions_version: tosca_simple_yaml_1_2

description: Simple deployment flavour for Sample VNF

imports:
  - etsi_nfv_sol001_common_types.yaml
  - etsi_nfv_sol001_vnfd_types.yaml
  - vnfd_types.yaml

topology_template:
  inputs:
    descriptor_id:
      type: string
    descriptor_version:
      type: string
    provider:
      type: string
    product_name:
      type: string
    software_version:
      type: string
    vnfm_info:
      type: list
      entry_schema:
        type: string
    flavour_id:
      type: string
    flavour_description:
      type: string

  substitution_mappings:
    node_type: {{ VNF.name }}
    properties:
      flavour_id: {{ VNF.flavour_id }}

  node_templates:
    VNF:
      type: {{ VNF.name }}
      properties:
        flavour_description: {{ VNF.flavour_description }}
      interfaces:
        Vnflcm:
          instantiate_start: [ ]
          instantiate_end: [ ]
          terminate_start: [ ]
          terminate_end: [ ]
          modify_information_start: [ ]
          modify_information_end: [ ]
          heal_start: [ ]
          heal_end: [ ]
          scale_start: [ ]
          scale_end: [ ]

    {{ server.name }}:
      type: tosca.nodes.nfv.Vdu.Compute
      properties:
        name: {{ server.name }}
        description: {{ server.name }} compute node
        vdu_profile:
          min_number_of_instances: {{ server.min_count }}
          max_number_of_instances: {{ server.max_count }}
        sw_image_data:
          name: "{{ image.id }}"
          version: "{{ image.version }}"
          checksum:
            algorithm: "{{ image.algorithm }}"
            hash: "{{ image.hash }}"
          container_format: "{{ image.container_format }}"
          disk_format: "{{ image.disk_format }}"
          min_disk: "{{ image.min_disk }} GB"
          size: "{{ image.size }} GB"
      capabilities:
        virtual_compute:
          properties:
            requested_additional_capabilities:
              properties:
                # OpenStack Nova Flavor的Name或ID
                requested_additional_capability_name: "{{ flavor.id }}"
                support_mandatory: true
                target_performance_parameters:
                  entry_schema: test
            virtual_memory:
              virtual_mem_size: "{{ flavor.mem }} MB"
            virtual_cpu:
              num_virtual_cpu: {{ flavor.vcpu }}
            virtual_local_storage:
              - size_of_storage: "{{ flavor.disk }} GB"
      {% if image.file -%}
      artifacts:
        # OpenStack镜像文件，存在就会新建。且每次实例化都会重新创建。
        sw_image:
          type: tosca.artifacts.nfv.SwImage
          file: {{ image.file }}
      {% endif %}
    {{ network.connect_point }}:
      type: tosca.nodes.nfv.VduCp
      properties:
        layer_protocols: [ ipv4 ]
        order: 4
      requirements:
        - virtual_binding: {{ server.name }}
        - virtual_link: {{ network.name }}

    {{ network.name }}:
      type: tosca.nodes.nfv.VnfVirtualLink
      properties:
        connectivity_type:
          layer_protocols: [ ipv4 ]
        description: Internal Virtual link in the VNF
        vl_profile:
          max_bitrate_requirements:
            # 1048576 bits/s = 1MiB/s
            root: 1048576
            leaf: 1048576
          min_bitrate_requirements:
            root: 1048576
            leaf: 1048576
          virtual_link_protocol_data:
            - associated_layer_protocol: ipv4
              l3_protocol_data:
                ip_version: ipv4
                cidr: {{ network.cidr }}

  policies:
    - scaling_aspects:
        type: tosca.policies.nfv.ScalingAspects
        properties:
          aspects:
            VDU1_scale:
              name: VDU1_scale
              description: VDU1 scaling aspect
              max_scale_level: 2
              step_deltas:
                - delta_1

    - VDU1_initial_delta:
        type: tosca.policies.nfv.VduInitialDelta
        properties:
          initial_delta:
            number_of_instances: 1
        targets: [ {{ server.name }} ]

    - VDU1_scaling_aspect_deltas:
        type: tosca.policies.nfv.VduScalingAspectDeltas
        properties:
          aspect: VDU1_scale
          deltas:
            delta_1:
              number_of_instances: 1
        targets: [ {{ server.name }} ]

    - instantiation_levels:
        type: tosca.policies.nfv.InstantiationLevels
        properties:
          levels:
            instantiation_level_1:
              description: Smallest size
              scale_info:
                VDU1_scale:
                  scale_level: 0
            instantiation_level_2:
              description: Largest size
              scale_info:
                VDU1_scale:
                  scale_level: 2
          default_level: instantiation_level_1

    - VDU1_instantiation_levels:
        type: tosca.policies.nfv.VduInstantiationLevels
        properties:
          levels:
            instantiation_level_1:
              number_of_instances: 1
            instantiation_level_2:
              number_of_instances: 3
        targets: [ {{ server.name }} ]

    - internalVL1_instantiation_levels:
        type: tosca.policies.nfv.VirtualLinkInstantiationLevels
        properties:
          levels:
            instantiation_level_1:
              bitrate_requirements:
                root: 1048576
                leaf: 1048576
            instantiation_level_2:
              bitrate_requirements:
                root: 1048576
                leaf: 1048576
        targets: [ {{ network.name }} ]